/**
 *
 * 防御士兵01
 * @author 
 *
 */
class ShieldSoldier01 extends ShieldSoldierBase{
    public hp:number = 260;
    public damage: number = 60;
    //每次点击生成长度为1的路径寻路点
	public constructor() {
        super();
        //纹理
        this.view = new egret.MovieClip();
        this.addChild(this.view);
	}
    /**添加纹理 初始化数据*/
    public addTexture(tietu: string,name: string) {
        this.nameInfo = name;
        var data = RES.getRes(tietu + "_json");
        var texture = RES.getRes(tietu + "_png");
        var mcf: egret.MovieClipDataFactory = new egret.MovieClipDataFactory(data,texture);
        this.view.movieClipData = mcf.generateMovieClipData(tietu);
        this.view.x = this.view.width / 2;
        //血条位置
        this.lifeBar.x = (this.view.width - this.lifeBar.width) / 2;
        this.lifeBar.y = -50;
        //初始不会变化的数据
        this._maxSpeed = 0.7;
        this.anchorOffsetX = this.width / 2;
        
        //this.damage = 20;
        //this.life = 40;
        this.offy = 10;
        this.fireDelay = 1000;
        
    }
	
    /**创建-初始化*/
    public onCreate(){
        this.posArr = [];
        this._pathIndex = 0;
        
        this.timesum = 0;
        this.lifeBar.reSet();
        this.canClear = false;
        
        this.atjijie = false;
        this.moveToTarget = false;
        
        
        this.fsm.changeState(stateType.moveState);
        this.curState = stateType.moveState;
        
        //this.view.touchEnabled = true;
        //this.view.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.viewSelect,this);
    }
    
    /**初始化 运动路径点 并移动*/
    public init(arr: number[][],life: number,damage: number):void {
        this.hp = this.life= life * (1 + 0.2 * GuankaBase.instance.lifeUp);
        this.damage = damage * (1 + 0.2 * GuankaBase.instance.damagekUp);
        
        this.atjijie = true;
        this._position.x = this.x = arr[0][0];
        this._position.y = this.y = arr[0][1];
        
        this.fsm.changeState(stateType.idleState);

    }
    
    public initRoad(arr: number[][]) {
        var i: number = 1;
        var len: number = arr.length;
        for(i;i < arr.length;i++) {
            this.jijieDian = new Vector2D(arr[i][0] + this.xoffset,arr[i][1] + this.yoffset);
            this.posArr.push(this.jijieDian);
        }
        this.fsm.changeState(stateType.moveState);
        this.ratioSoldY = this.minSoldRadius / this.maxSoldRadius;
    }
    
    /**帧事件*/
    public onEnterFrame(advancedTime:number){
        super.onEnterFrame(advancedTime);
    }
    
    
    /**销毁*/
    public onDestroy(): void {
        super.onDestroy();
    }
    
}
